version: '3.7'

# rif: https://levelup.gitconnected.com/set-up-an-sftp-server-with-docker-353fb513ccfd

networks:
  sftp-network:
    driver: bridge
    ipam:
      config:
        - subnet: ${SFTP_SUBNET}

services:
  sftp:
    container_name: dev-sftp-srv
    build:
      context: ./
      dockerfile: Dockerfile
    restart: always
    ports:
      - "22:22/tcp"
    command:
      - ${SFTP_USERNAME}:${SFTP_PASSWORD}:::${SFTP_SHARED}
    volumes:
      - ./${SFTP_SHARED}:/home/${SFTP_USERNAME}/${SFTP_SHARED}:rw
      - ./keys/ssh_host_rsa_key.pub:/home/${SFTP_USERNAME}/.ssh/ssh_host_rsa_key.pub:ro
      - ./keys/ssh_host_ed25519_key.pub:/home/${SFTP_USERNAME}/.ssh/ssh_host_ed25519_key.pub:ro
    networks:
      sftp-network:
        ipv4_address: ${SFTP_IP}
